Multiple editors - tricky JavaScript?

Last post 03-26-2004, 2:23 PM by Anonymous. 1 replies.
Sort Posts: Previous Next
  •  03-26-2004, 2:00 PM 605

    Multiple editors - tricky JavaScript?

    I have multiple, dynamically generated editors on my ASP page. When I save the page, however, I need the Javascript to loop through each editor to execute the Save function. However, the Save function doesn't seem to accept a generated string and is looking for something hardcoded. Is this true? Know of a workaround? Here's my code:

     

     for ( var i=0,n=document.forms[0].elements.length; i<n; i++ )
     {
         var field = document.forms[0].elements[i];
         myString = field.name;
         if (myString.indexOf("_HTMLContent") > 0) {
          myStringSave = myString.slice(0,myString.length-12);
    //      alert(myStringSave);
          save(myStringSave);   
      }
     }

     

    Thanks in advance for any help. Cheers, Kris.

  •  03-26-2004, 2:23 PM 606 in reply to 605

    Re: Multiple editors - tricky JavaScript?

    Figured it out. The Save function is looking for an object, so the dynamically generated Editor name should be encapsulated with the eval function. Fixed code:

     

     for ( var i=0,n=document.forms[0].elements.length; i<n; i++ )
     {
         var field = document.forms[0].elements[i];
         myString = field.name;
         if (myString.indexOf("_HTMLContent") > 0) {
          myStringSave = myString.slice(0,myString.length-12);
    //      alert(myStringSave);
          save(eval(myStringSave));   
      }
     }

     

    Cheers, Kris.

View as RSS news feed in XML